<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="post">
    <p>
        <span>用户名：</span><input type="text" id="username" required>
    </p>

    <p>
        <span>性别：</span>
        <input type="radio" name="sex" value="male">男
        <input type="radio" name="sex" value="female">女
    </p>

    <input type="submit" value="登录">
</form>

<script>
    var input_text = document.getElementById('username');
    var male_radio = document.getElementsByName('sex')[0];
    var female_radio = document.getElementsByName('sex')[1];
    //得到输入框的值
    input_text.value
    //修改输入框的值
    input_text.value = '123'

    //对于单选框和多选框等固定的值
    male_radio.checked;//查看返回的结果，是否为true，如果为true，则被选中
    female_radio.checked = true;//赋值

</script>
</body>
</html>